package com.hengxinguotong.zhihuichengjian.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.hengxinguotong.zhihuichengjian.R;
import com.hengxinguotong.zhihuichengjian.bean.CompanyAttendance;
import com.hengxinguotong.zhihuichengjian.treeview.RecyclerAdapter;
import com.hengxinguotong.zhihuichengjian.widget.font.HXTextView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @CopyRight 恒信国通信息科技
 * @Author WuLei
 * @Date 2019/4/4
 * <p>
 * 考勤报表-公司考勤明细
 */

public class AttendanceCompanyDetailAdapter extends RecyclerAdapter<CompanyAttendance, AttendanceCompanyDetailAdapter.AttendanceCompanyDetailViewHolder> {

    public AttendanceCompanyDetailAdapter(Context context, List<CompanyAttendance> dataList) {
        super(context, dataList);
    }

    @Override
    public AttendanceCompanyDetailViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.item_attendance_company_detail, null);
        return new AttendanceCompanyDetailViewHolder(view);
    }

    @Override
    public void onBindViewHolder(AttendanceCompanyDetailViewHolder holder, int position) {
        holder.bindData(position);
    }

    public class AttendanceCompanyDetailViewHolder extends RecyclerAdapter.BaseViewHolder<CompanyAttendance> {
        @BindView(R.id.company_name)
        HXTextView companyName;
        @BindView(R.id.clock_time)
        HXTextView clockTime;
        @BindView(R.id.attendance_rate)
        HXTextView attendanceRate;
        @BindView(R.id.attendance_person_number)
        HXTextView attendancePersonNumber;
        @BindView(R.id.local_person_number)
        HXTextView localPersonNumber;
        @BindView(R.id.total_person_number)
        HXTextView totalPersonNumber;

        public AttendanceCompanyDetailViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void bindData(int position) {
            CompanyAttendance companyAttendance = dataList.get(position);
            companyName.setText(companyAttendance.getName());
            clockTime.setText(companyAttendance.getClockTime());
            attendanceRate.setText(companyAttendance.getPercent());
            attendancePersonNumber.setText(String.valueOf(companyAttendance.getNum()));
            localPersonNumber.setText(String.valueOf(companyAttendance.getLocal()));
            totalPersonNumber.setText(String.valueOf(companyAttendance.getTotal()));
        }
    }
}
